package eteam.aps.controller;

import eteam.aps.common.R;
import eteam.aps.common.component.LoginUserRedisService;
import eteam.aps.common.exceptions.AuthException;
import eteam.aps.model.vo.ParamListVo;
import eteam.aps.model.vo.ParamVo;
import eteam.aps.model.vo.ProductParamVo;
import eteam.aps.service.ProductParamService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Set;

/**
 * 产品参数子表控制器
 *
 * @author WMT
 */
@Api(tags = "产品参数子表")
@RestController
public class ProductParamController implements IProductParamController{

    @Autowired
    private ProductParamService productParamService;

    @Autowired
    private LoginUserRedisService loginUserRedisService;

    @Override
    @ApiOperation("查询参数子表列表")
    @PostMapping("/pep/selectAll/{fDtlId}")
    public R<List<ProductParamVo>> selectAll(@PathVariable String fDtlId) throws Exception, AuthException {
        return R.success(productParamService.selectAll(fDtlId));
    }

    @Override
    @ApiOperation("删除产品参数")
    @PostMapping("/pep/delete/{fId}")
    public R<Integer> delete(@PathVariable String fId) throws Exception, AuthException {
        return R.success(productParamService.deleteByFId(fId));
    }


    @Override
    @ApiOperation("查询所有参数字典信息")
    @PostMapping("/pep/selectpardd")
    public R<Set<ParamListVo>> selectParDd() throws Exception, AuthException {
        return R.success(productParamService.selectParDd());
    }

    @Override
    @ApiOperation("查询参数子表字典信息")
    @PostMapping("/pep/selectDdInfo/{paramCode}")
    public R<Set<ParamVo>> selectDdInfo(@PathVariable String paramCode) throws Exception, AuthException {
        return R.success(productParamService.selectDdInfo(paramCode));
    }
}
